package com.cdivtc.management.controller;

import com.cdivtc.management.dao.RoleMapper;
import com.cdivtc.management.pojo.Role;
import com.cdivtc.management.pojo.testbean.FileDownload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//测试类
@RestController
public class TestController {

@Autowired
private RoleMapper roleMapper;
    @RequestMapping("/getData")
    public List<Map<String, Object>> getData() {
        List<Map<String, Object>> maps = new ArrayList<>();

        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("id",1);
        map1.put("label","信息工程学院");
        map1.put("value","xxgc");
        ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>();

        HashMap<String, Object> map11 = new HashMap<>();
        map11.put("id",1);
        map11.put("label","Z移动1701班");
        map11.put("value","1701");
        HashMap<String, Object> map12 = new HashMap<>();
        map12.put("id",2);
        map12.put("label","Z移动1702班");
        map12.put("value","1702");
        HashMap<String, Object> map13 = new HashMap<>();
        map13.put("id",3);
        map13.put("label","Z移动1703班");
        map13.put("value","1703");
        HashMap<String, Object> map14 = new HashMap<>();
        map14.put("id",4);
        map14.put("label","Z移动1704班");
        map14.put("value","1704");

        hashMaps.add(map11);
        hashMaps.add(map12);
        hashMaps.add(map13);
        hashMaps.add(map14);
        map1.put("classes",hashMaps);

        maps.add(map1);

        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("id",2);
        map2.put("label","建筑学院");
        map2.put("value","jjgc");
        ArrayList<HashMap<String, Object>> hashMaps2 = new ArrayList<>();

        HashMap<String, Object> map21 = new HashMap<>();
        map21.put("id",1);
        map21.put("label","Z建筑1701班");
        map21.put("value","1701");
        HashMap<String, Object> map22 = new HashMap<>();
        map22.put("id",2);
        map22.put("label","Z建筑1702班");
        map22.put("value","1702");
        HashMap<String, Object> map23 = new HashMap<>();
        map23.put("id",3);
        map23.put("label","Z建筑1703班");
        map23.put("value","1703");
        HashMap<String, Object> map24 = new HashMap<>();
        map24.put("id",4);
        map24.put("label","Z建筑1704班");
        map24.put("value","1704");

        hashMaps2.add(map21);
        hashMaps2.add(map22);
        hashMaps2.add(map23);
        hashMaps2.add(map24);
        map2.put("classes",hashMaps2);

        maps.add(map2);

        return maps;
    }

    @RequestMapping("/getImgUrl")
    public List<FileDownload> getImgUrl() {
        ArrayList<FileDownload> fileDownloads = new ArrayList<>();

        FileDownload fd = new FileDownload();
        fd.setType("img");
        List<String> strings = new ArrayList<>();
        strings.add("http://132.232.47.31:8080/image/w1.jpg");
        fd.setUrl(strings);

        FileDownload fd2 = new FileDownload();
        fd2.setType("file");
        List<String> strings2 = new ArrayList<>();
        strings2.add("http://132.232.47.31:8080/image/w1.jpg");
        strings2.add("http://132.232.47.31:8080/image/w2.jpg");
        fd2.setUrl(strings2);



        fileDownloads.add(fd);
        fileDownloads.add(fd2);


        return fileDownloads;
    }

    @GetMapping("/test")
    public List<Role> test(){
        List<Role> roleList = roleMapper.selectAll();
        return roleList;
    }


}
